<?php 

    echo phpinfo();exit;
    // $server ="WINDOWS-7A603F3\MSSQLSERVER1"; //服务器IP地址,如果是本地，可以写成localhost
    // $uid ="sa"; //用户名
    // $pwd ="123456"; //密码
    // $database ="xiaoyetest"; //数据库名称

    $server ="192.168.103.29"; //服务器IP地址,如果是本地，可以写成localhost
    $uid ="SouHua"; //用户名
    $pwd ="S@H#2023"; //密码
    $database ="NewHGERP"; //数据库名称


    $wuliaoname = 'GZ5205N';
    $conn = new PDO("sqlsrv:server=".$server.";database=".$database,$uid,$pwd);
    $sql = "select *  from vWmmHGSearchFlowersStock where 物料名称='".$wuliaoname."'";
    $res = $conn->query($sql);
    $newArr = array();
    $i =0;
    while ($row = $res->fetch()){
        $newArr[$i]['物料名称'] = $row['物料名称']?$row['物料名称']:'';
        $newArr[$i]['颜色'] = $row['颜色']?$row['颜色']:'';
        $newArr[$i]['客户色名'] = $row['客户色名']?$row['客户色名']:'';
        $newArr[$i]['卡号'] = $row['卡号']?$row['卡号']:'';
        $newArr[$i]['箱号'] = $row['箱号']?$row['箱号']:'';
        $newArr[$i]['库位'] = $row['库位']?$row['库位']:'';
        $newArr[$i]['等级'] = $row['等级']?$row['等级']:'';
        $newArr[$i]['库存重量'] = $row['库存重量']?$row['库存重量']:'';
        $newArr[$i]['库存长度'] = $row['库存长度']?$row['库存长度']:'';
        $newArr[$i]['单位'] = $row['单位']?$row['单位']:'';
        $newArr[$i]['最晚日期'] = $row['最晚日期']?$row['最晚日期']:'';
        $newArr[$i]['仓库名称'] = $row['仓库名称']?$row['仓库名称']:'';
        $newArr[$i]['库存类型'] = $row['库存类型']?$row['库存类型']:'';
        $newArr[$i]['布类'] = $row['布类']?$row['布类']:'';
        $newArr[$i]['机型'] = $row['机型']?$row['机型']:'';
        $newArr[$i]['排单余数'] = $row['排单余数']?$row['排单余数']:'';
        $i++;
    }

    var_dump($newArr);
   